using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CubeObj : MonoBehaviour
{
    public GameObject[] rewardObjs;
    public GameObject effObj;
    private void OnTriggerEnter(Collider other)
    {
        Destroy(this.gameObject);
        int rangeInt = Random.Range(0, 100);
        if (rangeInt < 50)
        {
            int rangeIndex = Random.Range(0, rewardObjs.Length);
            Instantiate(rewardObjs[rangeIndex], transform.position, transform.rotation);
        }

        GameObject eff = Instantiate(effObj, transform.position, transform.rotation);
        AudioSource audioSource = eff.GetComponent<AudioSource>();
        audioSource.volume = GameDataManager.Instance.musicData.soundValue;
        audioSource.mute = GameDataManager.Instance.musicData.isOpenSound;
    }
}
